/* -----------------------------------------------------------------------------
 * PROJECT    : net.lwf
 * FILE       : MathUtil.java
 *
 * HISTORY:
 * Date          Author                        Description
 * ----------------------------------------------------------------------------- 
 * Apr 5, 2009  Raghu Sarraff	 		        Created
 */
package net.lwf.handler.util;

import net.lwf.handler.constant.IHandlerConstant;
import net.lwf.number.util.RandomNumberGenerator;

public class MathUtil {

	/**
	 * @return Returns the random operation.
	 */
	public static String getOperation() {
			
		int operationIndex = RandomNumberGenerator.generate(1, 4);
		String randomoperation = null;
    	switch(operationIndex) {
		case 4:
			//Division
			randomoperation = IHandlerConstant.DIVISION;
			break;
		case 3:
			//Multiplication
			randomoperation = IHandlerConstant.MULTIPLICATION;
			break;
		case 2:
			//Subtraction
			randomoperation = IHandlerConstant.SUBTRACTION;
			break;
		default:
			//Addition
			randomoperation = IHandlerConstant.ADDITION;
    	}

    	return randomoperation;

	} //getOperation
	
	public static String getOperationsign(String operation) {
		
		if(operation != null && operation.equals(IHandlerConstant.SUBTRACTION)) {
			return "-";
		} else if(operation != null && operation.equals(IHandlerConstant.MULTIPLICATION)) {
			return "x";
		} else if(operation != null && operation.equals(IHandlerConstant.DIVISION)) {
			return "/";
		} else if(operation != null && operation.equals(IHandlerConstant.ADDITION)) {
			return "+";
		}
		return null;
	}
	
} //MathUtil

